package com.example.demo.service;

import com.example.demo.entity.DeviceEntity;
import com.example.demo.mapper.DeviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceService {
    @Autowired
    DeviceMapper deviceMapper;

    public List<DeviceEntity> findAll(DeviceEntity device) {
        return deviceMapper.findAll(device);
    }
    public boolean saveDevice(DeviceEntity device) {
        if (device.getId() > 0) {  //有ID则为更新，否则为添加
            return deviceMapper.update(device);
        } else {
            return deviceMapper.insert(device);
        }
    }

    public boolean delDevice(Integer id) {
        return deviceMapper.delete(id);
    }

    public int getCount(DeviceEntity device) {
        return deviceMapper.getCount(device);
    }

}
